const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));

export default {
    namespace: 'count',
    state: {
        num: 0,
    },
    reducers: {
        add(state: any) {
            // console.log(111);
            // return { ...state, num: state.num + 1 };
            state.num = state.num + 1;
        },
    },
    effects: {
        *addAsync(_action: any, { put }: any) {
            yield delay(1000);
            yield put({ type: 'add' });
        },
    },
};